{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Evaluate a polynomial string"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "def symbolize(s):\n",
    "    \"\"\"\n",
    "    Converts a a string (equation) to a SymPy symbol object\n",
    "    \"\"\"\n",
    "    from sympy import sympify\n",
    "    s1=s.replace('.','*')\n",
    "    s2=s1.replace('^','**')\n",
    "    s3=sympify(s2)\n",
    "    \n",
    "    return(s3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def eval_multinomial(s,vals=None,symbolic_eval=False):\n",
    "    \"\"\"\n",
    "    Evaluates polynomial at vals.\n",
    "    vals can be simple list, dictionary, or tuple of values.\n",
    "    vals can also contain symbols instead of real values provided those symbols have been declared before using SymPy\n",
    "    \"\"\"\n",
    "    from sympy import Symbol\n",
    "    sym_s=symbolize(s)\n",
    "    sym_set=sym_s.atoms(Symbol)\n",
    "    sym_lst=[]\n",
    "    for s in sym_set:\n",
    "        sym_lst.append(str(s))\n",
    "    sym_lst.sort()\n",
    "    if symbolic_eval==False and len(sym_set)!=len(vals):\n",
    "        print(\"Length of the input values did not match number of variables and symbolic evaluation is not selected\")\n",
    "        return None\n",
    "    else:\n",
    "        if type(vals)==list:\n",
    "            sub=list(zip(sym_lst,vals))\n",
    "        elif type(vals)==dict:\n",
    "            l=list(vals.keys())\n",
    "            l.sort()\n",
    "            lst=[]\n",
    "            for i in l:\n",
    "                lst.append(vals[i])\n",
    "            sub=list(zip(sym_lst,lst))\n",
    "        elif type(vals)==tuple:\n",
    "            sub=list(zip(sym_lst,list(vals)))\n",
    "        result=sym_s.subs(sub)\n",
    "    \n",
    "    return result"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Helper function for flipping binary values of a _ndarray_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def flip(y,p):\n",
    "    import numpy as np\n",
    "    lst=[]\n",
    "    for i in range(len(y)):\n",
    "        f=np.random.choice([1,0],p=[p,1-p])\n",
    "        lst.append(f)\n",
    "    lst=np.array(lst)\n",
    "    return np.array(np.logical_xor(y,lst),dtype=int)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Classification sample generation based on a symbolic expression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def gen_classification_symbolic(m=None,n_samples=100,n_features=2,flip_y=0.0):\n",
    "    \"\"\"\n",
    "    Generates classification sample based on a symbolic expression.\n",
    "    Calculates the output of the symbolic expression at randomly generated (Gaussian distribution) points and\n",
    "    assigns binary classification based on sign.\n",
    "    m: The symbolic expression. Needs x1, x2, etc as variables and regular python arithmatic symbols to be used.\n",
    "    n_samples: Number of samples to be generated\n",
    "    n_features: Number of variables. This is automatically inferred from the symbolic expression. So this is ignored \n",
    "                in case a symbolic expression is supplied. However if no symbolic expression is supplied then a \n",
    "                default simple polynomial can be invoked to generate classification samples with n_features.\n",
    "    flip_y: Probability of flipping the classification labels randomly. A higher value introduces more noise and make\n",
    "            the classification problem harder.\n",
    "    Returns a numpy ndarray with dimension (n_samples,n_features+1). Last column is the response vector.\n",
    "    \"\"\"\n",
    "    \n",
    "    import numpy as np\n",
    "    from sympy import Symbol,sympify\n",
    "    \n",
    "    if m==None:\n",
    "        m=''\n",
    "        for i in range(1,n_features+1):\n",
    "            c='x'+str(i)\n",
    "            c+=np.random.choice(['+','-'],p=[0.5,0.5])\n",
    "            m+=c\n",
    "        m=m[:-1]\n",
    "    sym_m=sympify(m)\n",
    "    n_features=len(sym_m.atoms(Symbol))\n",
    "    evals=[]\n",
    "    lst_features=[]\n",
    "    for i in range(n_features):\n",
    "        lst_features.append(np.random.normal(scale=5,size=n_samples))\n",
    "    lst_features=np.array(lst_features)\n",
    "    lst_features=lst_features.T\n",
    "    for i in range(n_samples):\n",
    "        evals.append(eval_multinomial(m,vals=list(lst_features[i])))\n",
    "    \n",
    "    evals=np.array(evals)\n",
    "    evals_binary=evals>0\n",
    "    evals_binary=evals_binary.flatten()\n",
    "    evals_binary=np.array(evals_binary,dtype=int)\n",
    "    evals_binary=flip(evals_binary,p=flip_y)\n",
    "    evals_binary=evals_binary.reshape(n_samples,1)\n",
    "    \n",
    "    lst_features=lst_features.reshape(n_samples,n_features)\n",
    "    x=np.hstack((lst_features,evals_binary))\n",
    "    \n",
    "    return (x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "x=gen_classification_symbolic(m='2*x1+3*x2+5*x3',n_samples=10,flip_y=0.0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "df=pd.DataFrame(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.442614</td>\n",
       "      <td>-0.523797</td>\n",
       "      <td>2.300378</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.463687</td>\n",
       "      <td>3.200522</td>\n",
       "      <td>4.309449</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-2.580825</td>\n",
       "      <td>-2.606877</td>\n",
       "      <td>5.845246</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.888534</td>\n",
       "      <td>3.727563</td>\n",
       "      <td>-3.174944</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-1.120233</td>\n",
       "      <td>-2.737827</td>\n",
       "      <td>-8.308171</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-4.832498</td>\n",
       "      <td>-6.591497</td>\n",
       "      <td>5.565251</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-2.326688</td>\n",
       "      <td>4.751803</td>\n",
       "      <td>3.309559</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-1.213919</td>\n",
       "      <td>-10.209268</td>\n",
       "      <td>2.447471</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-1.320891</td>\n",
       "      <td>0.770222</td>\n",
       "      <td>-8.735817</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2.150437</td>\n",
       "      <td>6.061752</td>\n",
       "      <td>-6.733177</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0          1         2    3\n",
       "0 -0.442614  -0.523797  2.300378  1.0\n",
       "1 -0.463687   3.200522  4.309449  1.0\n",
       "2 -2.580825  -2.606877  5.845246  1.0\n",
       "3  0.888534   3.727563 -3.174944  0.0\n",
       "4 -1.120233  -2.737827 -8.308171  0.0\n",
       "5 -4.832498  -6.591497  5.565251  0.0\n",
       "6 -2.326688   4.751803  3.309559  1.0\n",
       "7 -1.213919 -10.209268  2.447471  0.0\n",
       "8 -1.320891   0.770222 -8.735817  0.0\n",
       "9  2.150437   6.061752 -6.733177  0.0"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.566707</td>\n",
       "      <td>7.645691</td>\n",
       "      <td>0.559811</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-10.528796</td>\n",
       "      <td>2.241197</td>\n",
       "      <td>-4.216359</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5.000866</td>\n",
       "      <td>0.615997</td>\n",
       "      <td>2.021055</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2.919458</td>\n",
       "      <td>3.593280</td>\n",
       "      <td>0.498438</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4.671159</td>\n",
       "      <td>-0.679506</td>\n",
       "      <td>-5.125242</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-4.484902</td>\n",
       "      <td>-12.881067</td>\n",
       "      <td>2.340985</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1.302499</td>\n",
       "      <td>-5.054502</td>\n",
       "      <td>-1.396578</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-2.321861</td>\n",
       "      <td>-2.548314</td>\n",
       "      <td>2.881654</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-7.021660</td>\n",
       "      <td>4.530175</td>\n",
       "      <td>2.701544</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-9.778964</td>\n",
       "      <td>-0.132642</td>\n",
       "      <td>4.021956</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           0          1         2    3\n",
       "0   5.566707   7.645691  0.559811  1.0\n",
       "1 -10.528796   2.241197 -4.216359  0.0\n",
       "2   5.000866   0.615997  2.021055  1.0\n",
       "3   2.919458   3.593280  0.498438  1.0\n",
       "4   4.671159  -0.679506 -5.125242  1.0\n",
       "5  -4.484902 -12.881067  2.340985  1.0\n",
       "6   1.302499  -5.054502 -1.396578  0.0\n",
       "7  -2.321861  -2.548314  2.881654  0.0\n",
       "8  -7.021660   4.530175  2.701544  0.0\n",
       "9  -9.778964  -0.132642  4.021956  0.0"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=gen_classification_symbolic(m='12*x1/(x2+5*x3)',n_samples=10,flip_y=0.2)\n",
    "df=pd.DataFrame(x)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Regression sample generation based on a symbolic expression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def gen_regression_symbolic(m=None,n_samples=100,n_features=2,noise=0.0,noise_dist='normal'):\n",
    "    \"\"\"\n",
    "    Generates regression sample based on a symbolic expression. Calculates the output of the symbolic expression \n",
    "    at randomly generated (drawn from a Gaussian distribution) points\n",
    "    m: The symbolic expression. Needs x1, x2, etc as variables and regular python arithmatic symbols to be used.\n",
    "    n_samples: Number of samples to be generated\n",
    "    n_features: Number of variables. This is automatically inferred from the symbolic expression. So this is ignored \n",
    "                in case a symbolic expression is supplied. However if no symbolic expression is supplied then a \n",
    "                default simple polynomial can be invoked to generate regression samples with n_features.\n",
    "    noise: Magnitude of Gaussian noise to be introduced (added to the output).\n",
    "    noise_dist: Type of the probability distribution of the noise signal. \n",
    "    Currently supports: Normal, Uniform, t, Beta, Gamma, Poission, Laplace\n",
    "\n",
    "    Returns a numpy ndarray with dimension (n_samples,n_features+1). Last column is the response vector.\n",
    "    \"\"\"\n",
    "    \n",
    "    import numpy as np\n",
    "    from sympy import Symbol,sympify\n",
    "    \n",
    "    if m==None:\n",
    "        m=''\n",
    "        for i in range(1,n_features+1):\n",
    "            c='x'+str(i)\n",
    "            c+=np.random.choice(['+','-'],p=[0.5,0.5])\n",
    "            m+=c\n",
    "        m=m[:-1]\n",
    "    \n",
    "    sym_m=sympify(m)\n",
    "    n_features=len(sym_m.atoms(Symbol))\n",
    "    evals=[]\n",
    "    lst_features=[]\n",
    "    \n",
    "    for i in range(n_features):\n",
    "        lst_features.append(np.random.normal(scale=5,size=n_samples))\n",
    "    lst_features=np.array(lst_features)\n",
    "    lst_features=lst_features.T\n",
    "    lst_features=lst_features.reshape(n_samples,n_features)\n",
    "    \n",
    "    for i in range(n_samples):\n",
    "        evals.append(eval_multinomial(m,vals=list(lst_features[i])))\n",
    "    \n",
    "    evals=np.array(evals)\n",
    "    evals=evals.reshape(n_samples,1)\n",
    "    \n",
    "    if noise_dist=='normal':\n",
    "        noise_sample=noise*np.random.normal(loc=0,scale=1.0,size=n_samples)\n",
    "    elif noise_dist=='uniform':\n",
    "        noise_sample=noise*np.random.uniform(low=0,high=1.0,size=n_samples)\n",
    "    elif noise_dist=='beta':\n",
    "        noise_sample=noise*np.random.beta(a=0.5,b=1.0,size=n_samples)\n",
    "    elif noise_dist=='Gamma':\n",
    "        noise_sample=noise*np.random.gamma(shape=1.0,scale=1.0,size=n_samples)\n",
    "    elif noise_dist=='laplace':\n",
    "        noise_sample=noise*np.random.laplace(loc=0.0,scale=1.0,size=n_samples)\n",
    "        \n",
    "    noise_sample=noise_sample.reshape(n_samples,1)\n",
    "    evals=evals+noise_sample\n",
    "        \n",
    "    x=np.hstack((lst_features,evals))\n",
    "    \n",
    "    return (x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Generate samples with a rational function as input \n",
    "### $$\\frac{10x_1}{(3x_2+4x_3)}$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-7.08499</td>\n",
       "      <td>-4.35839</td>\n",
       "      <td>8.10732</td>\n",
       "      <td>-3.67783156896633</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-10.6684</td>\n",
       "      <td>0.779056</td>\n",
       "      <td>-6.64651</td>\n",
       "      <td>4.45796155973331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-6.69542</td>\n",
       "      <td>-5.307</td>\n",
       "      <td>1.17935</td>\n",
       "      <td>5.95108211351032</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-3.83581</td>\n",
       "      <td>6.46401</td>\n",
       "      <td>-5.99678</td>\n",
       "      <td>8.28104884665168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-1.50995</td>\n",
       "      <td>-1.46056</td>\n",
       "      <td>-4.10213</td>\n",
       "      <td>0.493224249022704</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2.22995</td>\n",
       "      <td>-1.12163</td>\n",
       "      <td>4.41009</td>\n",
       "      <td>1.51213441402200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>4.26261</td>\n",
       "      <td>0.982687</td>\n",
       "      <td>7.0676</td>\n",
       "      <td>1.31581579041464</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.787195</td>\n",
       "      <td>2.20071</td>\n",
       "      <td>-4.68889</td>\n",
       "      <td>-0.724650906335961</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.720728</td>\n",
       "      <td>-2.32469</td>\n",
       "      <td>-0.468637</td>\n",
       "      <td>-0.917106940761226</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-3.04485</td>\n",
       "      <td>-3.26701</td>\n",
       "      <td>-3.19083</td>\n",
       "      <td>1.40239700700260</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1         2                   3\n",
       "0  -7.08499  -4.35839   8.10732   -3.67783156896633\n",
       "1  -10.6684  0.779056  -6.64651    4.45796155973331\n",
       "2  -6.69542    -5.307   1.17935    5.95108211351032\n",
       "3  -3.83581   6.46401  -5.99678    8.28104884665168\n",
       "4  -1.50995  -1.46056  -4.10213   0.493224249022704\n",
       "5   2.22995  -1.12163   4.41009    1.51213441402200\n",
       "6   4.26261  0.982687    7.0676    1.31581579041464\n",
       "7  0.787195   2.20071  -4.68889  -0.724650906335961\n",
       "8  0.720728  -2.32469 -0.468637  -0.917106940761226\n",
       "9  -3.04485  -3.26701  -3.19083    1.40239700700260"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=gen_regression_symbolic(m='10*x1/(3*x2+4*x3)',n_samples=10,noise=0.1)\n",
    "df=pd.DataFrame(x)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Generate samples with no symbolic input and with 10 features"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-3.55302</td>\n",
       "      <td>-3.60695</td>\n",
       "      <td>-10.0729</td>\n",
       "      <td>7.85252</td>\n",
       "      <td>-3.76276</td>\n",
       "      <td>7.78251</td>\n",
       "      <td>-0.638193</td>\n",
       "      <td>-4.75034</td>\n",
       "      <td>-0.989603</td>\n",
       "      <td>0.181414</td>\n",
       "      <td>-10.2675547899900</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-6.34778</td>\n",
       "      <td>-2.74753</td>\n",
       "      <td>-4.75187</td>\n",
       "      <td>4.70489</td>\n",
       "      <td>2.70014</td>\n",
       "      <td>5.29475</td>\n",
       "      <td>-0.190095</td>\n",
       "      <td>4.85289</td>\n",
       "      <td>-4.50207</td>\n",
       "      <td>-1.22839</td>\n",
       "      <td>-1.93507315813350</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2.15057</td>\n",
       "      <td>-0.43572</td>\n",
       "      <td>-5.47805</td>\n",
       "      <td>6.96074</td>\n",
       "      <td>3.10096</td>\n",
       "      <td>-1.50898</td>\n",
       "      <td>1.09913</td>\n",
       "      <td>4.73097</td>\n",
       "      <td>-0.216513</td>\n",
       "      <td>-3.25629</td>\n",
       "      <td>4.91632094325713</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.11181</td>\n",
       "      <td>5.62156</td>\n",
       "      <td>0.0660036</td>\n",
       "      <td>6.66565</td>\n",
       "      <td>1.88656</td>\n",
       "      <td>-4.57167</td>\n",
       "      <td>-0.84389</td>\n",
       "      <td>-2.44545</td>\n",
       "      <td>1.66649</td>\n",
       "      <td>7.36169</td>\n",
       "      <td>18.0607243993836</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-3.27857</td>\n",
       "      <td>-4.13545</td>\n",
       "      <td>4.36299</td>\n",
       "      <td>-3.73405</td>\n",
       "      <td>-1.3958</td>\n",
       "      <td>-6.39237</td>\n",
       "      <td>1.99202</td>\n",
       "      <td>-0.216661</td>\n",
       "      <td>-10.3905</td>\n",
       "      <td>3.43896</td>\n",
       "      <td>-23.7181534803553</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-6.78726</td>\n",
       "      <td>-7.76895</td>\n",
       "      <td>-2.2653</td>\n",
       "      <td>-3.4326</td>\n",
       "      <td>-16.8937</td>\n",
       "      <td>-1.79111</td>\n",
       "      <td>4.79866</td>\n",
       "      <td>-4.43692</td>\n",
       "      <td>2.01342</td>\n",
       "      <td>-3.46766</td>\n",
       "      <td>-49.7886776301048</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1.66157</td>\n",
       "      <td>-4.34424</td>\n",
       "      <td>6.69391</td>\n",
       "      <td>-3.42321</td>\n",
       "      <td>-8.63976</td>\n",
       "      <td>0.862722</td>\n",
       "      <td>2.70897</td>\n",
       "      <td>-13.5047</td>\n",
       "      <td>-7.14555</td>\n",
       "      <td>-3.16143</td>\n",
       "      <td>-33.7432854958296</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3.46949</td>\n",
       "      <td>7.11633</td>\n",
       "      <td>-1.08523</td>\n",
       "      <td>6.41709</td>\n",
       "      <td>-1.23161</td>\n",
       "      <td>7.07956</td>\n",
       "      <td>6.6377</td>\n",
       "      <td>6.06688</td>\n",
       "      <td>-4.99262</td>\n",
       "      <td>3.85005</td>\n",
       "      <td>19.9862211512126</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1.13155</td>\n",
       "      <td>4.02597</td>\n",
       "      <td>-3.05607</td>\n",
       "      <td>4.9271</td>\n",
       "      <td>-3.60454</td>\n",
       "      <td>6.06252</td>\n",
       "      <td>0.936673</td>\n",
       "      <td>4.07096</td>\n",
       "      <td>-2.04052</td>\n",
       "      <td>5.11093</td>\n",
       "      <td>15.8002295267657</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-1.6051</td>\n",
       "      <td>4.97768</td>\n",
       "      <td>-7.69743</td>\n",
       "      <td>-0.65865</td>\n",
       "      <td>4.07053</td>\n",
       "      <td>2.98333</td>\n",
       "      <td>-10.9341</td>\n",
       "      <td>4.9402</td>\n",
       "      <td>2.9771</td>\n",
       "      <td>0.68357</td>\n",
       "      <td>21.5880195549236</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        0        1          2        3        4         5         6   \\\n",
       "0 -3.55302 -3.60695   -10.0729  7.85252 -3.76276   7.78251 -0.638193   \n",
       "1 -6.34778 -2.74753   -4.75187  4.70489  2.70014   5.29475 -0.190095   \n",
       "2  2.15057 -0.43572   -5.47805  6.96074  3.10096  -1.50898   1.09913   \n",
       "3  1.11181  5.62156  0.0660036  6.66565  1.88656  -4.57167  -0.84389   \n",
       "4 -3.27857 -4.13545    4.36299 -3.73405  -1.3958  -6.39237   1.99202   \n",
       "5 -6.78726 -7.76895    -2.2653  -3.4326 -16.8937  -1.79111   4.79866   \n",
       "6  1.66157 -4.34424    6.69391 -3.42321 -8.63976  0.862722   2.70897   \n",
       "7  3.46949  7.11633   -1.08523  6.41709 -1.23161   7.07956    6.6377   \n",
       "8  1.13155  4.02597   -3.05607   4.9271 -3.60454   6.06252  0.936673   \n",
       "9  -1.6051  4.97768   -7.69743 -0.65865  4.07053   2.98333  -10.9341   \n",
       "\n",
       "         7         8         9                  10  \n",
       "0  -4.75034 -0.989603  0.181414  -10.2675547899900  \n",
       "1   4.85289  -4.50207  -1.22839  -1.93507315813350  \n",
       "2   4.73097 -0.216513  -3.25629   4.91632094325713  \n",
       "3  -2.44545   1.66649   7.36169   18.0607243993836  \n",
       "4 -0.216661  -10.3905   3.43896  -23.7181534803553  \n",
       "5  -4.43692   2.01342  -3.46766  -49.7886776301048  \n",
       "6  -13.5047  -7.14555  -3.16143  -33.7432854958296  \n",
       "7   6.06688  -4.99262   3.85005   19.9862211512126  \n",
       "8   4.07096  -2.04052   5.11093   15.8002295267657  \n",
       "9    4.9402    2.9771   0.68357   21.5880195549236  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=gen_regression_symbolic(n_features=10,n_samples=10,noise=0.1)\n",
    "df=pd.DataFrame(x)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Generate samples with less noise and plot: $0.2x^2+1.2x+6+f_{noise}(x\\mid{N=0.1})$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAFQZJREFUeJzt3X+MHPV5x/HP482Srmmls4Xj2AcXo9R1heMEqydwlfyRQBLTH8GHlSAISK4a1a2UVEqDrrUDEqYhMuopraI0reo0KK7iQkxqFpOkvYKVKi0CknPXznGBK26IgTXBTsP1RziF4/z0j5016/P+mP0xuzv7fb8ky7uzezvf5ZIPwzPPPGPuLgDA4FvW6wUAALqDwAeAQBD4ABAIAh8AAkHgA0AgCHwACASBDwCBIPABIBAEPgAE4k29XkClSy65xNetW9frZQBAqhw9evQn7r6q0fv6KvDXrVunqampXi8DAFLFzE7GeR8lHQAIBIEPAIFoO/DN7BfM7LtmdtzMZszsrmj7SjN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Hg5/WDgfsfNcvdi9PdpM3tQpTJXSIH/spmtcfeXzGyNpNO9XlBclHQ6K6ix0NH/2MtuUOlk9qD7nqT1Zna5mV2k0kn6wz1eU9eY2cVm9kvlx5I+qDB+75UOS9oRPd4hKTX/xc8RfgvM7AZJX5C0StI3zeyYu28NcCz0n5nZlSqVdH4k6fd7u5zkufvrZvYJSZOSMpLudfeZHi+rm1ZLejAah/4mSX/v7v/U2yUlx8zuk/ReSZeY2YuS7pR0j6SDZvYxlab73ti7FTaHK20BIBCUdAAgEAQ+AASCwAeAQBD4ABAIAh8AAkHgA0AgCHwACASBDwCB+H/0CnQH9nV5lgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1fce05fba58>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=gen_regression_symbolic(m='0.2*x**2+1.2*x+6',n_samples=100,noise=0.1)\n",
    "df=pd.DataFrame(x)\n",
    "plt.scatter(df[0],df[1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Generate samples with more noise and plo: $0.2x^2+1.2x+6+f_{noise}(x\\mid{N=10})$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAGyVJREFUeJzt3X+sX3V9x/Hnu9c7uGxqS2hquXBtjRUHM9J4Q7bUGRRY0SmtbDpcltTMrDNBN1lSKXMZaELsRra5bO5HtxG7DKU4pXSyidDKnEbEW1t+FCRUBeFaoArNZtqxS/veH/d8y5fbc77f8z2/PufH65EQvr/uOZ/zvb3v8znvz/vzOebuiIhI+y0K3QAREamGAr6ISEco4IuIdIQCvohIRyjgi4h0hAK+iEhHKOCLiHSEAr6ISEco4IuIdMTLQjeg3xl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73H2cnsCF6vAG4LWBbMmni30Mt72lrZu8G/gpYCtxuZvvcfS3wFuATZjYHHAc+6O61HUhJOg53329mtwAPAS8AV7r7sZBtTelPzex85i+/HwN+N2xz0nH3F8zsQ8AdwBhwo7vvD9ysUS0DbjUzmP+7/ay7fzlsk9Ixs88BFwJnmNmTwLXAFuAWM/sA8yvkvjdcC4dLOIYLm/b3oJm2IiId0aiUjoiIZKeALyLSEQr4IiIdoYAvItIRCvgiIh2hgC8i0hEK+CIiHaGALyLSEf8P8KLGmCfMiOwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1fce36c19e8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=gen_regression_symbolic(m='0.2*x**2+1.2*x+6',n_samples=100,noise=10)\n",
    "df=pd.DataFrame(x)\n",
    "plt.scatter(df[0],df[1])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Generate samples with larger coefficent for the quadratic term and plot: $1.3x^2+1.2x+6+f_{noise}(x\\mid{N=10})$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAGftJREFUeJzt3X+MHOd93/H3R+eTclTTHgWdWWkplizK0BArWAcdVANKi0huTLWpzYtcKwyagkAFsAGUNnKLa8m0iCingogK+VG0Vgo1NcIidiTaok9nK4gsU0KNGnXkY48yfbIIMZYUcS2JjK1zYutCHY/f/nGz1N7dzN0u98fMzn5eAHGzz87sPrPL+94zz/Od51FEYGZm5XVF3hUwM7POcqA3Mys5B3ozs5JzoDczKzkHejOzknOgNzMrOQd6M7OSc6A3Mys5B3ozs5J7X94VALj22mtj69ateVfDzKynHD9+/M8jYmS9/QoR6Ldu3cr09HT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alVcd20nSQUnVuu/uH+ddp3aRdGfyXZ2WtD/v+nSCpFclnUy+u+m869MOkj4j6aykb9eVXSPpGUkvJz835lnHTso90APfBu4Cvpby3J9GxM3Jv1/ucr3aKfUcJd3I0nq6O4E7gUckDaw+vCf9dt13V4qVxpLv5tPAPwJuBH4x+Q7L6PbkuytL+uHvs/Q7Vm8/cCwitgPHksellHugj4jvRMSpvOvRSWuc427gsYg4HxGvAKeBW7tbO2vCrcDpiPhuRLwLPMbSd2gFFxFfA36wong3cDjZPgyMd7VSXZR7oF/HtuTy8X9L+vt5V6YDKsDrdY/PJGVl8K8kfSu5ZC7LJXGZv696AXxV0nFJ+/KuTAdtiog3ku03gU15VqaTurLwiKSvAn8z5an/EBFPZhz2BrAlIr4v6RZgUtLOiPiLjlW0BZd5jj1rrfMFfhf4DZYCxm8Avwn8i+7Vzlr00xFRlfR+4BlJLyUt4tKKiJBU2hTErgT6iPiHl3HMeeB8sn1c0p8CPwUUcnDocs4RqAI31D3enJQVXqPnK+l/AF/ucHW6pWe/r2ZERDX5eVbSF1nqsipjoH9L0nUR8Yak64CzeVeoUwrbdSNppDYwKelvA9uB7+Zbq7abAvZIukrSNpbO8fmc69Sy5Jem5udZGowug28C2yVtk3QlSwPpUznXqa0kXS3pJ2vbwEcoz/e30hSwN9neC5Tuyrsm9zVjJf088F+BEeApSSciYhfwD4BPSVoALgK/HBErB1N6QtY5RsSspCPAi8AF4N6IWMyzrm3ynyXdzFLXzavAv8y3Ou0RERck/QrwNDAAfCYiZnOuVrttAr4oCZbiw+ci4o/zrVLrJP0h8DPAtZLOAPcDh4Ajku4BXgPuzq+GneU7Y83MSq6wXTdmZtYeDvRmZiXnQG9mVnIO9GZmJedAb2ZWcg70ZmYl50BvZlZyDvRmZiX3/wG9BVl8wqbiCwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1fce36cde10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x=gen_regression_symbolic(m='1.3*x**2+1.2*x+6',n_samples=100,noise=10)\n",
    "df=pd.DataFrame(x)\n",
    "plt.scatter(df[0],df[1])\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autoclose": false,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
